// 接口 
interface ArrItem {   
    name: string;
    age: number
}

let arr: number[] = [1, 2, 3, 4, 5]

let arr1: ArrItem[] = [  //如果是数组的话，接口只是代表数组中每一项的类型，所以接口名称后要接上[]
    {
        name: 'lxf',
        age: 12
    },
    {
        name: 'lc',
        age: 17
    }
]

interface Arr {
    name: string,
    age: number,
    children?: Arr[]  //第二层也是数组，所以children的类型要是数组，但第二层没有children属性，所以要是可选的属性
}

let arr2: Arr[] = [
    {
        name: 'lxf',
        age: 23,
        children: [
            {
                name: 'llf',
                age: 19
            },
            {
                name: 'gjh',
                age: 21
            }
        ]
    },
    {
        name: 'lc',
        age: 28,
        children: [
            {
                name: 'lz',
                age: 20
            },
            {
                name: 'ws',
                age: 24
            }
        ]
    }
]

interface Obj {
    readonly name: string;  //只读属性，不能进行更改
    age: number;
    [propsName:string]:string|number  //可选属性，可选属性的类型需要包括上面所有属性的类型
}

let obj: Obj = {
    name: 'lxf',
    age: 23,
    address:'jzs',
    sex:'nv'
}

console.log(obj);

interface ArrIndex{
    [index:number]:number
}
let arr3:ArrIndex=[1,2,3]


